﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="main.aspx.cs" Inherits="Basic4Net.OAWeb.Module_Accounting.main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../App_Themes/ui-lightness/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="mainWarp">
        <div class="pageBody">
            <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
            </asp:ScriptManager>
            <asp:HiddenField ID="hidHaveMonth" runat="server" />
            <asp:HiddenField ID="hidVidify" runat="server" />
            <div id="divNoMonth" style="text-align: left; vertical-align: middle; width: 680px;
                border: 2px solid #c3dce5; padding: 50px 50px 50px 50px; display: none;">
                <label>
                    没有激活核算月, 请进入"流程管理"页面设置一个当前核算月.</label>
            </div>
            <div id="divMain" style=" padding-left:10px; padding-top:10px;">
                <asp:Label ID="labMsg" runat="server" Text=""></asp:Label>
                <input type="button" id="btnSave" value="保存" onclick="SaveClick();" class="commonBut"/>
                <div style=" display:none">
                    <asp:Button ID="btnF5" runat="server" Text="" OnClick="BtnF5Click"/>
                </div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                        <table id="teacherTable" border="0" cellpadding="0" cellspacing="1" class="useList1"
                            style="width: 840px; margin-top:10px;">
                            <tr class="tableTitle">
                                <th style="text-align: center; width: 120px;">
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    月实际工作量
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    月全勤工资
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    月安全资金
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    月全勤工资扣发额
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    月安全资金扣发额
                                </th>
                                <th style="text-align: center; width: 120px;">
                                    班补
                                </th>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr id="<%#Eval("RID")%>" objType="<%#Eval("ObjectRules")%>">
                            <td style="text-align:left; padding-left:5px;">
                                <%#Eval("RuleName")%>
                            </td>
                            <td>
                                <input type="checkbox" value="ActualWorkload" <%#Eval("ActualWorkload").ToString() == "1" ? "checked" : ""%> disabled="disabled"/>
                            </td>
                            <td>
                                <input type="checkbox" value="Attendance" <%#Eval("Attendance").ToString() == "1" ? "checked" : ""%>/>
                            </td>
                            <td>
                                <input type="checkbox" value="Safety" <%#Eval("Safety").ToString() == "1" ? "checked" : ""%>/>
                            </td>
                            <td>
                                <input type="checkbox" value="DeductAtt" <%#Eval("DeductAtt").ToString() == "1" ? "checked" : ""%>/>
                            </td>
                            <td>
                                <input type="checkbox" value="DeductSaf" <%#Eval("DeductSaf").ToString() == "1" ? "checked" : ""%>/>
                            </td>
                            <td>
                                <input type="checkbox" value="SubsidyCls" <%#Eval("SubsidyCls").ToString() == "1" ? "checked" : ""%> />
                            </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </table>
                    </FooterTemplate>
                </asp:Repeater>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnF5" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            </div>
            </form>
        </div>
    </div>
</body>
<script type="text/javascript" src="../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="../Scripts/common.js"></script>
<script type="text/javascript" src="../Scripts/Util.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        if ($("#<%=hidHaveMonth.ClientID %>").val() == "1") {
            $("#divNoMonth").css("display", "block");
            $("#divMain").css("display", "none");
        }
        if ($("#<%=hidVidify.ClientID %>").val() == "1") {
            $("#btnSave").hide();
            $("input[type='checkbox']").attr("disabled", "true");
        }
    });

    // 保存按钮
    function SaveClick() {
        var trList = $("tr[id]");
        var resArr = [];
        for (var i = 0; i < $(trList).size(); i++) {
            var dic = {};
            var tr = $(trList).eq(i);
            dic['RID'] = Number($(tr).attr("id"));
            dic['ObjectRules'] = Number($(tr).attr("objType"));
            dic['ActualWorkload'] = $(tr).find("input[value='ActualWorkload']").attr("checked") ? 1 : 0;
            dic['Attendance'] = $(tr).find("input[value='Attendance']").attr("checked") ? 1 : 0;
            dic['Safety'] = $(tr).find("input[value='Safety']").attr("checked") ? 1 : 0;
            dic['DeductAtt'] = $(tr).find("input[value='DeductAtt']").attr("checked") ? 1 : 0;
            dic['DeductSaf'] = $(tr).find("input[value='DeductSaf']").attr("checked") ? 1 : 0;
            dic['SubsidyCls'] = $(tr).find("input[value='SubsidyCls']").attr("checked") ? 1 : 0;
            resArr.push(dic);
        }
        if (resArr.length < 1) {
            showMassgeBox("提示", "保存失败", 1);
        }
        PageMethods.SaveRules(resArr,
            function (succ) {
                if (succ == null || succ.length < 1)
                    showMassgeBox("提示", "保存成功", 1);
                else
                    showMassgeBox("提示", succ, 1);
                $("#btnF5").click();
            },
            function (err) {
                if (err == null || err.length < 1)
                    showMassgeBox("提示", "保存失败", 1);
                else
                    showMassgeBox("提示", err, 1);
                $("#btnF5").click();
            }
        );
    }

</script>
</html>
